﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Web;
using System.Globalization;
//using MsWord = Microsoft.Office.Interop.Word;
using System.Diagnostics;
using System.Threading;

using iTextSharp;
using iTextSharp.text;
using iTextSharp.text.pdf;

using BMS.Models;
using BMS.Models.DataAccess;

namespace BMS.Utilities
{
    public static class PDFUtil
    {
        //public static bool WordToPDF(String srcFilePath, String destFilePath)
        //{
        //    bool isSuccess = false;

        //    try
        //    {
        //        //String arguments = "/c " + Configuration.PDFConverterPath + Configuration.Space
        //        //    + srcFilePath + Configuration.Space + destFilePath;
        //        ////ProcessStartInfo CMDStartInfo = new ProcessStartInfo(Configuration.CommandPromptExeFile, arguments);
        //        ////Process.Start(CMDStartInfo);
        //        //Process CMDProcess = new Process();
        //        //CMDProcess.StartInfo.FileName = Configuration.CommandPromptExeFile;
        //        //CMDProcess.StartInfo.Arguments = arguments;
        //        //CMDProcess.StartInfo.UseShellExecute = false;
        //        //CMDProcess.StartInfo.RedirectStandardInput = true;
        //        //CMDProcess.StartInfo.RedirectStandardOutput = true;
        //        //CMDProcess.StartInfo.RedirectStandardError = true;
        //        //CMDProcess.StartInfo.CreateNoWindow = true;
        //        //CMDProcess.Start();

        //        //Thread.Sleep(500);

                

        //        object tempName2 = srcFilePath;
        //        object missing = System.Type.Missing;
        //        object oFalse = false;
        //        object oTrue = true;
        //        object visible = false;
        //        object readOnly = true;


        //        MsWord.Application app = new MsWord.Application();
        //        MsWord.Document wordDoc = app.Documents.Open(ref tempName2, ref missing, ref readOnly, ref missing, ref missing, ref missing,
        //        ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing,
        //        ref missing, ref missing, ref missing);

        //        object exportFilePath = destFilePath;
        //        wordDoc.ExportAsFixedFormat(destFilePath, MsWord.WdExportFormat.wdExportFormatPDF, false, MsWord.WdExportOptimizeFor.wdExportOptimizeForOnScreen,
        //                            MsWord.WdExportRange.wdExportAllDocument, 0, 0, MsWord.WdExportItem.wdExportDocumentContent, false, false,
        //                            MsWord.WdExportCreateBookmarks.wdExportCreateNoBookmarks, false, false, false, ref missing);
                
        //        //object format = MsWord.WdSaveFormat.wdFormatPDF;
        //        //wordDoc.SaveAs2(ref exportFilePath, ref format, ref missing, ref missing, ref missing, ref missing, ref missing,
        //        //ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
        //        object salvar = false;
        //        wordDoc.Close(ref salvar, ref missing, ref missing);
        //        app.Quit(ref salvar, ref missing, ref missing);

        //        //releaseObject(wordDoc);
        //        //releaseObject(app);

                

        //        isSuccess = true;
        //    }
        //    catch(Exception e)
        //    {
        //        isSuccess = false;
        //    }

        //    return isSuccess;
        //}

        //private static void releaseObject(object obj)
        //{
        //    try
        //    {
        //        System.Runtime.InteropServices.Marshal.ReleaseComObject(obj);
        //        obj = null;
        //    }
        //    catch (Exception ex)
        //    {
        //        obj = null;
        //    }
        //    finally
        //    {
        //        GC.Collect();
        //    }
        //}

        //public static void MergePDFs(string outPutFilePath, params string[] filesPath)
        //{
        //    List<PdfReader> readerList = new List<PdfReader>();
        //    foreach (string filePath in filesPath)
        //    {
        //        PdfReader pdfReader = new PdfReader(filePath);
        //        readerList.Add(pdfReader);
        //    }

        //    //Define a new output document and its size, type
        //    Document document = new Document(PageSize.A4, 0, 0, 0, 0);
        //    //Create blank output pdf file and get the stream to write on it.
        //    PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(outPutFilePath, FileMode.Create));
        //    document.Open();

        //    foreach (PdfReader reader in readerList)
        //    {
        //        for (int i = 1; i <= reader.NumberOfPages; i++)
        //        {
        //            PdfImportedPage page = writer.GetImportedPage(reader, i);
        //            document.Add(iTextSharp.text.Image.GetInstance(page));
        //        }
        //    }
        //    document.Close();
        //}

        //public static bool PDFCreation(String destPath, String destFileName, PDF_QuotationInvoiceModel pdfQuotation)
        //{
        //    FMRepository fmRepsoitory = new FMRepository();
        //    bool isSuccess = false;
        //    int StandardFontSize = 9;
        //    int HeaderFontSizeChinese = 18;
        //    int HeaderFontSizeEnglish = 14;
        //    int StandardFontSize1 = 1;
        //    int StandardFontSize2 = 10;
        //    float StandardFontSize3 = 0.01f;
        //    int StandardFontSize8 = 8;
        //    int StandardFontSize13 = 13;
        //    int NoOfItems = (pdfQuotation.QuotationItemsList != null)? pdfQuotation.QuotationItemsList.Count : 15;
        //    int NoOfPages = (int)Math.Ceiling((double)NoOfItems / (double)pdfQuotation.MaxNoOfRecords);

        //    var PDFDoc = new Document(PageSize.A4, 30, 30, 30, 20);
        //    PdfWriter pdfWriter = PdfWriter.GetInstance(PDFDoc, new FileStream(destPath + destFileName, FileMode.Create));

        //    try
        //    {
        //        PDFDoc.Open();
        //        Decimal TotalAmount = 0;

        //        for (int j = 0; j < NoOfPages; j++)
        //        {
        //            PDFDoc.NewPage();

        //            int currentPage = j + 1;

        //            #region Part I - Company Info
        //            PdfPTable pdfTable = new PdfPTable(2);
        //            pdfTable.TotalWidth = 500f;
        //            pdfTable.LockedWidth = true;
        //            float[] widths = new float[] { 3f, 2f };
        //            pdfTable.SetWidths(widths);

        //            #region Row 1 - Company Name & Company Image
        //            PdfPTable nestedTable = new PdfPTable(1);

        //            PdfPCell HeaderCell1 = new PdfPCell(new Phrase(pdfQuotation.CompanyNameInChinese, CreateChineseFontWithBold(HeaderFontSizeChinese)));
        //            HeaderCell1.HorizontalAlignment = Element.ALIGN_LEFT;
        //            HeaderCell1.Border = PdfPCell.NO_BORDER;
        //            nestedTable.AddCell(HeaderCell1);
        //            PdfPCell HeaderCell2 = new PdfPCell(new Phrase(pdfQuotation.CompanyNameInEnglish, CreateEnglishFontWithBold(HeaderFontSizeEnglish)));
        //            HeaderCell2.HorizontalAlignment = Element.ALIGN_LEFT;
        //            HeaderCell2.Border = PdfPCell.NO_BORDER;
        //            nestedTable.AddCell(HeaderCell2);
        //            PdfPCell nesthousing = new PdfPCell(nestedTable);
        //            nesthousing.Padding = 0f;
        //            nesthousing.Border = PdfPCell.NO_BORDER;
        //            pdfTable.AddCell(nesthousing);

        //            Image jpg = Image.GetInstance(pdfQuotation.CompanyLogoPath);
        //            jpg.ScaleAbsolute(140, 60);
        //            PdfPCell imageCell = new PdfPCell(jpg);
        //            imageCell.Border = PdfPCell.NO_BORDER;
        //            imageCell.HorizontalAlignment = Element.ALIGN_RIGHT;
        //            pdfTable.AddCell(imageCell);
        //            #endregion

        //            #region Row 2 - Empty Row
        //            PdfPCell EmptyCell = new PdfPCell(new Phrase("\n", CreateFont(StandardFontSize)));
        //            EmptyCell.HorizontalAlignment = Element.ALIGN_LEFT;
        //            EmptyCell.Border = PdfPCell.BOTTOM_BORDER;
        //            EmptyCell.Colspan = 2;
        //            EmptyCell.BorderWidthBottom = 2f;
        //            pdfTable.AddCell(EmptyCell);
        //            #endregion

        //            PDFDoc.Add(pdfTable);
        //            Paragraph p = new Paragraph("\n");
        //            PDFDoc.Add(p);
        //            #endregion

        //            #region Part II - Billing Info
        //            PdfPTable BillInfoTable = new PdfPTable(4);
        //            BillInfoTable.TotalWidth = 500f;
        //            BillInfoTable.LockedWidth = true;
        //            widths = new float[] { 1f, 4f, 2f, 2f };
        //            BillInfoTable.SetWidths(widths);
        //            String tempDNOrQuoNo = "";

        //            if (pdfQuotation.IsQuotation == true)
        //            {
        //                #region Row 1 - Bill To & Quotation No
        //                PdfPCell cell = new PdfPCell(new Phrase("Bill To :", CreateFont(StandardFontSize2)));
        //                cell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                cell.Border = PdfPCell.NO_BORDER;
        //                BillInfoTable.AddCell(cell);

        //                cell = new PdfPCell(new Phrase(pdfQuotation.client.ClientName, CreateFont(StandardFontSize2)));
        //                cell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                cell.Border = PdfPCell.NO_BORDER;
        //                BillInfoTable.AddCell(cell);

        //                cell = new PdfPCell(new Phrase("Quot No. :", CreateFont(StandardFontSize2)));
        //                cell.HorizontalAlignment = Element.ALIGN_RIGHT;
        //                cell.Border = PdfPCell.NO_BORDER;
        //                BillInfoTable.AddCell(cell);

        //                String[] QuoNoSplit = pdfQuotation.QuotationNo.Split('-');
        //                String tempQuoNo = "";

        //                for (int i = 1; i < QuoNoSplit.Length; i++)
        //                {
        //                    if (i != QuoNoSplit.Length -1)
        //                        tempQuoNo += QuoNoSplit[i] + "-";
        //                    else
        //                        tempQuoNo += QuoNoSplit[i];
        //                }

        //                cell = new PdfPCell(new Phrase(tempQuoNo, CreateFont(StandardFontSize2)));
        //                cell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                cell.Border = PdfPCell.NO_BORDER;
        //                BillInfoTable.AddCell(cell);
        //                #endregion

        //                #region Row 2 - Bill Address & Work Order No
        //                cell = new PdfPCell(new Phrase("", CreateFont(StandardFontSize2)));
        //                cell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                cell.Border = PdfPCell.NO_BORDER;
        //                BillInfoTable.AddCell(cell);

        //                cell = new PdfPCell(new Phrase(pdfQuotation.client.Address1, CreateFont(StandardFontSize2)));
        //                cell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                cell.Border = PdfPCell.NO_BORDER;
        //                BillInfoTable.AddCell(cell);

        //                cell = new PdfPCell(new Phrase("Work Order :", CreateFont(StandardFontSize2)));
        //                cell.HorizontalAlignment = Element.ALIGN_RIGHT;
        //                cell.Border = PdfPCell.NO_BORDER;
        //                BillInfoTable.AddCell(cell);

        //                cell = new PdfPCell(new Phrase(pdfQuotation.WorkOrderNo, CreateFont(StandardFontSize2)));
        //                cell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                cell.Border = PdfPCell.NO_BORDER;
        //                BillInfoTable.AddCell(cell);
        //                #endregion

        //                #region Row 3 - Bill Address & Quotation Date
        //                cell = new PdfPCell(new Phrase("", CreateFont(StandardFontSize2)));
        //                cell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                cell.Border = PdfPCell.NO_BORDER;
        //                BillInfoTable.AddCell(cell);

        //                cell = new PdfPCell(new Phrase(pdfQuotation.client.Address2, CreateFont(StandardFontSize2)));
        //                cell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                cell.Border = PdfPCell.NO_BORDER;
        //                BillInfoTable.AddCell(cell);

        //                cell = new PdfPCell(new Phrase("Date :", CreateFont(StandardFontSize2)));
        //                cell.HorizontalAlignment = Element.ALIGN_RIGHT;
        //                cell.Border = PdfPCell.NO_BORDER;
        //                BillInfoTable.AddCell(cell);

        //                cell = new PdfPCell(new Phrase(pdfQuotation.QuotationDate.ToString("dd-MMM-yyyy", CultureInfo.CreateSpecificCulture("en-US")), CreateFont(StandardFontSize2)));
        //                cell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                cell.Border = PdfPCell.NO_BORDER;
        //                BillInfoTable.AddCell(cell);
        //                #endregion

        //                #region Row 4 - Bill Address & Pages
        //                cell = new PdfPCell(new Phrase("", CreateFont(StandardFontSize2)));
        //                cell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                cell.Border = PdfPCell.NO_BORDER;
        //                BillInfoTable.AddCell(cell);

        //                cell = new PdfPCell(new Phrase(pdfQuotation.client.Address3, CreateFont(StandardFontSize2)));
        //                cell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                cell.Border = PdfPCell.NO_BORDER;
        //                BillInfoTable.AddCell(cell);

        //                cell = new PdfPCell(new Phrase("Page(s) :", CreateFont(StandardFontSize2)));
        //                cell.HorizontalAlignment = Element.ALIGN_RIGHT;
        //                cell.Border = PdfPCell.NO_BORDER;
        //                BillInfoTable.AddCell(cell);

        //                String tempPage = currentPage + " of " + NoOfPages;
        //                cell = new PdfPCell(new Phrase(tempPage, CreateFont(StandardFontSize2)));
        //                cell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                cell.Border = PdfPCell.NO_BORDER;
        //                BillInfoTable.AddCell(cell);
        //                #endregion

        //                #region Row 5 - Reference No (Service Order No)
        //                cell = new PdfPCell(new Phrase("", CreateFont(StandardFontSize2)));
        //                cell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                cell.Border = PdfPCell.NO_BORDER;
        //                BillInfoTable.AddCell(cell);

        //                cell = new PdfPCell(new Phrase("", CreateFont(StandardFontSize2)));
        //                cell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                cell.Border = PdfPCell.NO_BORDER;
        //                BillInfoTable.AddCell(cell);

        //                cell = new PdfPCell(new Phrase("Ref :", CreateFont(StandardFontSize2)));
        //                cell.HorizontalAlignment = Element.ALIGN_RIGHT;
        //                cell.Border = PdfPCell.NO_BORDER;
        //                BillInfoTable.AddCell(cell);

        //                cell = new PdfPCell(new Phrase(pdfQuotation.ReferenceNo, CreateFont(StandardFontSize2)));
        //                cell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                cell.Border = PdfPCell.NO_BORDER;
        //                BillInfoTable.AddCell(cell);
        //                #endregion

        //                #region Row 6 - Attention To & Vendor No
        //                cell = new PdfPCell(new Phrase("Attn. :", CreateFont(StandardFontSize2)));
        //                cell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                cell.Border = PdfPCell.NO_BORDER;
        //                BillInfoTable.AddCell(cell);

        //                cell = new PdfPCell(new Phrase(pdfQuotation.client.AttentionTo, CreateFont(StandardFontSize2)));
        //                cell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                cell.Border = PdfPCell.NO_BORDER;
        //                BillInfoTable.AddCell(cell);

        //                cell = new PdfPCell(new Phrase("Vendor No. :", CreateFont(StandardFontSize2)));
        //                cell.HorizontalAlignment = Element.ALIGN_RIGHT;
        //                cell.Border = PdfPCell.NO_BORDER;
        //                BillInfoTable.AddCell(cell);

        //                cell = new PdfPCell(new Phrase(pdfQuotation.VendorNo, CreateFont(StandardFontSize2)));
        //                cell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                cell.Border = PdfPCell.NO_BORDER;
        //                BillInfoTable.AddCell(cell);
        //                #endregion
        //            }
        //            else if (pdfQuotation.IsInvoice == true)
        //            {
        //                #region Row 1 - Bill To & Invoice No
        //                PdfPCell cell = new PdfPCell(new Phrase("Bill To :", CreateFont(StandardFontSize2)));
        //                cell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                cell.Border = PdfPCell.NO_BORDER;
        //                BillInfoTable.AddCell(cell);

        //                cell = new PdfPCell(new Phrase(pdfQuotation.client.ClientName, CreateFont(StandardFontSize2)));
        //                cell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                cell.Border = PdfPCell.NO_BORDER;
        //                BillInfoTable.AddCell(cell);

        //                cell = new PdfPCell(new Phrase("Invoice No. :", CreateFont(StandardFontSize2)));
        //                cell.HorizontalAlignment = Element.ALIGN_RIGHT;
        //                cell.Border = PdfPCell.NO_BORDER;
        //                BillInfoTable.AddCell(cell);

        //                String[] InvNoSplit = pdfQuotation.InvoiceNo.Split('-');
        //                String tempInvNo = "";

        //                for (int i = 1; i < InvNoSplit.Length; i++ )
        //                {
        //                    if (i != InvNoSplit.Length - 1)
        //                        tempInvNo += InvNoSplit[i] + "-";
        //                    else
        //                        tempInvNo += InvNoSplit[i];
        //                }

        //                cell = new PdfPCell(new Phrase(tempInvNo, CreateFont(StandardFontSize2)));
        //                cell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                cell.Border = PdfPCell.NO_BORDER;
        //                BillInfoTable.AddCell(cell);
        //                #endregion

        //                #region Row 2 - Bill Address & Debit Note No
        //                cell = new PdfPCell(new Phrase("", CreateFont(StandardFontSize2)));
        //                cell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                cell.Border = PdfPCell.NO_BORDER;
        //                BillInfoTable.AddCell(cell);

        //                cell = new PdfPCell(new Phrase(pdfQuotation.client.Address1, CreateFont(StandardFontSize2)));
        //                cell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                cell.Border = PdfPCell.NO_BORDER;
        //                BillInfoTable.AddCell(cell);

        //                cell = new PdfPCell(new Phrase("Ref :", CreateFont(StandardFontSize2)));
        //                cell.HorizontalAlignment = Element.ALIGN_RIGHT;
        //                cell.Border = PdfPCell.NO_BORDER;
        //                BillInfoTable.AddCell(cell);

        //                if (pdfQuotation.InvoiceItemList.Count == 1)
        //                {
        //                    String[] QuoNoSplit = pdfQuotation.Invoice.DNNo.Split('-');
        //                    for (int i = 1; i < QuoNoSplit.Length; i++)
        //                    {
        //                        if (i != QuoNoSplit.Length - 1)
        //                            tempDNOrQuoNo += QuoNoSplit[i] + "-";
        //                        else
        //                            tempDNOrQuoNo += QuoNoSplit[i];
        //                    }
        //                }
        //                else
        //                    tempDNOrQuoNo = pdfQuotation.Invoice.DNNo;

        //                cell = new PdfPCell(new Phrase(tempDNOrQuoNo, CreateFont(StandardFontSize2)));
        //                cell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                cell.Border = PdfPCell.NO_BORDER;
        //                BillInfoTable.AddCell(cell);
        //                #endregion

        //                #region Row 3 - Bill Address & Invoice Creation Date
        //                cell = new PdfPCell(new Phrase("", CreateFont(StandardFontSize2)));
        //                cell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                cell.Border = PdfPCell.NO_BORDER;
        //                BillInfoTable.AddCell(cell);

        //                cell = new PdfPCell(new Phrase(pdfQuotation.client.Address2, CreateFont(StandardFontSize2)));
        //                cell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                cell.Border = PdfPCell.NO_BORDER;
        //                BillInfoTable.AddCell(cell);

        //                cell = new PdfPCell(new Phrase("Date :", CreateFont(StandardFontSize2)));
        //                cell.HorizontalAlignment = Element.ALIGN_RIGHT;
        //                cell.Border = PdfPCell.NO_BORDER;
        //                BillInfoTable.AddCell(cell);

        //                cell = new PdfPCell(new Phrase(pdfQuotation.InvoiceDate.ToString("dd-MMM-yyyy", CultureInfo.CreateSpecificCulture("en-US")), CreateFont(StandardFontSize2)));
        //                cell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                cell.Border = PdfPCell.NO_BORDER;
        //                BillInfoTable.AddCell(cell);
        //                #endregion

        //                #region Row 4 - Bill Address & Vendor No
        //                cell = new PdfPCell(new Phrase("", CreateFont(StandardFontSize2)));
        //                cell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                cell.Border = PdfPCell.NO_BORDER;
        //                BillInfoTable.AddCell(cell);

        //                cell = new PdfPCell(new Phrase(pdfQuotation.client.Address3, CreateFont(StandardFontSize2)));
        //                cell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                cell.Border = PdfPCell.NO_BORDER;
        //                BillInfoTable.AddCell(cell);

        //                cell = new PdfPCell(new Phrase("Vendor No. :", CreateFont(StandardFontSize2)));
        //                cell.HorizontalAlignment = Element.ALIGN_RIGHT;
        //                cell.Border = PdfPCell.NO_BORDER;
        //                BillInfoTable.AddCell(cell);

        //                cell = new PdfPCell(new Phrase(pdfQuotation.VendorNo, CreateFont(StandardFontSize2)));
        //                cell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                cell.Border = PdfPCell.NO_BORDER;
        //                BillInfoTable.AddCell(cell);
        //                #endregion

        //                #region Row 5 - Empty Row
        //                cell = new PdfPCell(new Phrase("\n", CreateFont(StandardFontSize2)));
        //                cell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                cell.Border = PdfPCell.NO_BORDER;
        //                BillInfoTable.AddCell(cell);

        //                cell = new PdfPCell(new Phrase("\n", CreateFont(StandardFontSize2)));
        //                cell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                cell.Border = PdfPCell.NO_BORDER;
        //                BillInfoTable.AddCell(cell);

        //                cell = new PdfPCell(new Phrase("\n", CreateFont(StandardFontSize2)));
        //                cell.HorizontalAlignment = Element.ALIGN_RIGHT;
        //                cell.Border = PdfPCell.NO_BORDER;
        //                BillInfoTable.AddCell(cell);

        //                cell = new PdfPCell(new Phrase("\n", CreateFont(StandardFontSize2)));
        //                cell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                cell.Border = PdfPCell.NO_BORDER;
        //                BillInfoTable.AddCell(cell);
        //                #endregion

        //                #region Row 6 - Empty Row
        //                cell = new PdfPCell(new Phrase("\n", CreateFont(StandardFontSize2)));
        //                cell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                cell.Border = PdfPCell.NO_BORDER;
        //                BillInfoTable.AddCell(cell);

        //                cell = new PdfPCell(new Phrase("\n", CreateFont(StandardFontSize2)));
        //                cell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                cell.Border = PdfPCell.NO_BORDER;
        //                BillInfoTable.AddCell(cell);

        //                cell = new PdfPCell(new Phrase("\n", CreateFont(StandardFontSize2)));
        //                cell.HorizontalAlignment = Element.ALIGN_RIGHT;
        //                cell.Border = PdfPCell.NO_BORDER;
        //                BillInfoTable.AddCell(cell);

        //                cell = new PdfPCell(new Phrase("\n", CreateFont(StandardFontSize2)));
        //                cell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                cell.Border = PdfPCell.NO_BORDER;
        //                BillInfoTable.AddCell(cell);
        //                #endregion

        //                #region Row 7 - Attention To
        //                cell = new PdfPCell(new Phrase("Attn. :", CreateFont(StandardFontSize2)));
        //                cell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                cell.Border = PdfPCell.NO_BORDER;
        //                BillInfoTable.AddCell(cell);

        //                cell = new PdfPCell(new Phrase(pdfQuotation.client.AttentionTo, CreateFont(StandardFontSize2)));
        //                cell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                cell.Border = PdfPCell.NO_BORDER;
        //                BillInfoTable.AddCell(cell);

        //                cell = new PdfPCell(new Phrase("", CreateFont(StandardFontSize2)));
        //                cell.HorizontalAlignment = Element.ALIGN_RIGHT;
        //                cell.Border = PdfPCell.NO_BORDER;
        //                BillInfoTable.AddCell(cell);

        //                cell = new PdfPCell(new Phrase("", CreateFont(StandardFontSize2)));
        //                cell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                cell.Border = PdfPCell.NO_BORDER;
        //                BillInfoTable.AddCell(cell);
        //                #endregion
        //            }

        //            PDFDoc.Add(BillInfoTable);
        //            p = new Paragraph("\n");
        //            PDFDoc.Add(p);
        //            #endregion

        //            if (pdfQuotation.IsQuotation == true)
        //            {
        //                #region Quotation Part
        //                #region Part III - Quotation
        //                PdfPTable qTable = new PdfPTable(1);
        //                qTable.TotalWidth = 500f;
        //                qTable.LockedWidth = true;
        //                #region Section Header
        //                PdfPCell hCell = new PdfPCell(new Phrase("\n", CreateFont(StandardFontSize3)));
        //                hCell.HorizontalAlignment = Element.ALIGN_CENTER;
        //                hCell.Border = PdfPCell.TOP_BORDER;
        //                qTable.AddCell(hCell);

        //                if (pdfQuotation.IsQuotation == true)
        //                {
        //                    hCell = new PdfPCell(new Phrase("QUOTATION", CreateEnglishFontWithBold(HeaderFontSizeChinese)));
        //                    hCell.HorizontalAlignment = Element.ALIGN_CENTER;
        //                    hCell.Border = PdfPCell.TOP_BORDER;
        //                    qTable.AddCell(hCell);
        //                }
        //                else if (pdfQuotation.IsInvoice == true)
        //                {
        //                    hCell = new PdfPCell(new Phrase("INVOICE", CreateEnglishFontWithBold(HeaderFontSizeChinese)));
        //                    hCell.HorizontalAlignment = Element.ALIGN_CENTER;
        //                    hCell.Border = PdfPCell.TOP_BORDER;
        //                    qTable.AddCell(hCell);
        //                }

        //                hCell = new PdfPCell(new Phrase("\n", CreateFont(StandardFontSize3)));
        //                hCell.HorizontalAlignment = Element.ALIGN_CENTER;
        //                hCell.Border = PdfPCell.BOTTOM_BORDER;
        //                qTable.AddCell(hCell);

        //                hCell = new PdfPCell(new Phrase("\n", CreateFont(StandardFontSize3)));
        //                hCell.HorizontalAlignment = Element.ALIGN_CENTER;
        //                hCell.Border = PdfPCell.BOTTOM_BORDER;
        //                qTable.AddCell(hCell);

        //                hCell = new PdfPCell(new Phrase("\n", CreateFont(StandardFontSize3)));
        //                hCell.HorizontalAlignment = Element.ALIGN_CENTER;
        //                hCell.Border = PdfPCell.NO_BORDER;
        //                qTable.AddCell(hCell);
        //                #endregion

        //                PDFDoc.Add(qTable);

        //                #region Service Address
        //                PdfPTable SATable = new PdfPTable(2);
        //                SATable.TotalWidth = 500f;
        //                SATable.LockedWidth = true;
        //                widths = new float[] { 0.3f, 5f };
        //                SATable.SetWidths(widths);

        //                hCell = new PdfPCell(new Phrase("RE :", CreateEnglishFontWithBold(StandardFontSize2)));
        //                hCell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                hCell.Border = PdfPCell.NO_BORDER;
        //                SATable.AddCell(hCell);

        //                String tStrn = pdfQuotation.Location + " - " + pdfQuotation.ServiceDetail;

        //                if (pdfQuotation.ServiceDetail == "" || pdfQuotation.ServiceDetail == null)
        //                    tStrn = pdfQuotation.Location;

        //                hCell = new PdfPCell(new Phrase(tStrn, CreateFontWithBoldAndUnderline(StandardFontSize2)));
        //                hCell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                hCell.Border = PdfPCell.NO_BORDER;
        //                SATable.AddCell(hCell);

        //                hCell = new PdfPCell(new Phrase("\n", CreateFont(StandardFontSize2)));
        //                hCell.HorizontalAlignment = Element.ALIGN_CENTER;
        //                hCell.Border = PdfPCell.NO_BORDER;
        //                SATable.AddCell(hCell);

        //                PDFDoc.Add(SATable);
        //                p = new Paragraph("\n");
        //                PDFDoc.Add(p);
        //                #endregion

        //                #region Quotation / Invoice Header
        //                PdfPTable QuotationTable = new PdfPTable(7);
        //                QuotationTable.TotalWidth = 500f;
        //                QuotationTable.LockedWidth = true;
        //                widths = new float[] { 1f, 5f, 1f, 1f, 1f, 2f, 2f };
        //                QuotationTable.SetWidths(widths);

        //                #region Row 1 - Header
        //                hCell = new PdfPCell(new Phrase("Item", CreateFontWithBoldAndUnderline(StandardFontSize2)));
        //                hCell.HorizontalAlignment = Element.ALIGN_CENTER;
        //                hCell.Border = PdfPCell.NO_BORDER;
        //                QuotationTable.AddCell(hCell);

        //                hCell = new PdfPCell(new Phrase("Description", CreateFontWithBoldAndUnderline(StandardFontSize2)));
        //                hCell.HorizontalAlignment = Element.ALIGN_CENTER;
        //                hCell.Border = PdfPCell.NO_BORDER;
        //                QuotationTable.AddCell(hCell);

        //                hCell = new PdfPCell(new Phrase("SOR Item", CreateFontWithBoldAndUnderline(StandardFontSize2)));
        //                hCell.HorizontalAlignment = Element.ALIGN_CENTER;
        //                hCell.Border = PdfPCell.NO_BORDER;
        //                QuotationTable.AddCell(hCell);

        //                hCell = new PdfPCell(new Phrase("Qty", CreateFontWithBoldAndUnderline(StandardFontSize2)));
        //                hCell.HorizontalAlignment = Element.ALIGN_CENTER;
        //                hCell.Border = PdfPCell.NO_BORDER;
        //                QuotationTable.AddCell(hCell);

        //                hCell = new PdfPCell(new Phrase("Unit", CreateFontWithBoldAndUnderline(StandardFontSize2)));
        //                hCell.HorizontalAlignment = Element.ALIGN_CENTER;
        //                hCell.Border = PdfPCell.NO_BORDER;
        //                QuotationTable.AddCell(hCell);

        //                hCell = new PdfPCell(new Phrase("Rate", CreateFontWithBoldAndUnderline(StandardFontSize2)));
        //                hCell.HorizontalAlignment = Element.ALIGN_CENTER;
        //                hCell.Border = PdfPCell.NO_BORDER;
        //                QuotationTable.AddCell(hCell);

        //                hCell = new PdfPCell(new Phrase("Amount (HKD)", CreateFontWithBoldAndUnderline(StandardFontSize2)));
        //                hCell.HorizontalAlignment = Element.ALIGN_CENTER;
        //                hCell.Border = PdfPCell.NO_BORDER;
        //                QuotationTable.AddCell(hCell);
        //                #endregion

        //                #region Row 2 - Empty Row / Brought Forward
        //                if (j >= 1 && j < NoOfPages)
        //                {
        //                    #region Brought Forward
        //                    hCell = new PdfPCell(new Phrase("\n", CreateFont(StandardFontSize2)));
        //                    hCell.HorizontalAlignment = Element.ALIGN_CENTER;
        //                    hCell.Border = PdfPCell.NO_BORDER;
        //                    QuotationTable.AddCell(hCell);

        //                    hCell = new PdfPCell(new Phrase("\n", CreateFont(StandardFontSize2)));
        //                    hCell.HorizontalAlignment = Element.ALIGN_CENTER;
        //                    hCell.Border = PdfPCell.NO_BORDER;
        //                    QuotationTable.AddCell(hCell);

        //                    hCell = new PdfPCell(new Phrase("\n", CreateFont(StandardFontSize2)));
        //                    hCell.HorizontalAlignment = Element.ALIGN_CENTER;
        //                    hCell.Border = PdfPCell.NO_BORDER;
        //                    QuotationTable.AddCell(hCell);

        //                    hCell = new PdfPCell(new Phrase("\n", CreateFont(StandardFontSize2)));
        //                    hCell.HorizontalAlignment = Element.ALIGN_CENTER;
        //                    hCell.Border = PdfPCell.NO_BORDER;
        //                    QuotationTable.AddCell(hCell);

        //                    hCell = new PdfPCell(new Phrase("Brought Forward:", CreateFont(StandardFontSize2)));
        //                    hCell.HorizontalAlignment = Element.ALIGN_CENTER;
        //                    hCell.Border = PdfPCell.NO_BORDER;
        //                    hCell.Colspan = 2;
        //                    QuotationTable.AddCell(hCell);

        //                    hCell = new PdfPCell(new Phrase(TotalAmount.ToString("#,##0.00"), CreateFont(StandardFontSize2)));
        //                    hCell.HorizontalAlignment = Element.ALIGN_CENTER;
        //                    hCell.Border = PdfPCell.BOTTOM_BORDER;
        //                    QuotationTable.AddCell(hCell);
        //                    #endregion

        //                    #region Empty Row
        //                    hCell = new PdfPCell(new Phrase("\n", CreateFontWithBoldAndUnderline(StandardFontSize2)));
        //                    hCell.HorizontalAlignment = Element.ALIGN_CENTER;
        //                    hCell.Border = PdfPCell.NO_BORDER;
        //                    hCell.Colspan = 7;
        //                    QuotationTable.AddCell(hCell);
        //                    #endregion
        //                }
        //                else
        //                {
        //                    #region Empty Row
        //                    hCell = new PdfPCell(new Phrase("\n", CreateFontWithBoldAndUnderline(StandardFontSize2)));
        //                    hCell.HorizontalAlignment = Element.ALIGN_CENTER;
        //                    hCell.Border = PdfPCell.NO_BORDER;
        //                    hCell.Colspan = 7;
        //                    QuotationTable.AddCell(hCell);
        //                    #endregion
        //                }
        //                #endregion

        //                int StartIndex = GetStartIndex(pdfQuotation, j);
        //                int EndIndex = GetEndIndex(pdfQuotation, currentPage, NoOfPages);
        //                String tempStrn = "";
        //                #region Row 3 onwards - Item List
        //                if (pdfQuotation.IsQuotation == true)
        //                {
        //                    #region Quotation Item
        //                    //foreach (JLLOrderQuotation JOItem in pdfQuotation.JOQuotationList)
        //                    for (int sIndex = StartIndex; sIndex < EndIndex; sIndex++)
        //                    {
        //                        tempStrn = (pdfQuotation.QuotationItemsList[sIndex].ItemNo == 0) ? "" : pdfQuotation.QuotationItemsList[sIndex].ItemNo.ToString("00") + ".";
        //                        hCell = new PdfPCell(new Phrase(tempStrn, CreateFont(StandardFontSize2)));
        //                        hCell.HorizontalAlignment = Element.ALIGN_CENTER;
        //                        hCell.Border = PdfPCell.NO_BORDER;
        //                        QuotationTable.AddCell(hCell);

        //                        hCell = new PdfPCell(new Phrase(pdfQuotation.QuotationItemsList[sIndex].ItemDescription, CreateFont(StandardFontSize2)));
        //                        hCell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                        hCell.Border = PdfPCell.NO_BORDER;
        //                        QuotationTable.AddCell(hCell);

        //                        hCell = new PdfPCell(new Phrase(pdfQuotation.QuotationItemsList[sIndex].SORItem, CreateFontWithUnderline(StandardFontSize2)));
        //                        hCell.HorizontalAlignment = Element.ALIGN_CENTER;
        //                        hCell.Border = PdfPCell.NO_BORDER;
        //                        QuotationTable.AddCell(hCell);

        //                        tempStrn = (pdfQuotation.QuotationItemsList[sIndex].Qty == 0) ? "" : pdfQuotation.QuotationItemsList[sIndex].Qty.ToString("0");
        //                        hCell = new PdfPCell(new Phrase(tempStrn, CreateFont(StandardFontSize2)));
        //                        hCell.HorizontalAlignment = Element.ALIGN_CENTER;
        //                        hCell.Border = PdfPCell.NO_BORDER;
        //                        QuotationTable.AddCell(hCell);

        //                        hCell = new PdfPCell(new Phrase(pdfQuotation.QuotationItemsList[sIndex].Unit, CreateFont(StandardFontSize2)));
        //                        hCell.HorizontalAlignment = Element.ALIGN_CENTER;
        //                        hCell.Border = PdfPCell.NO_BORDER;
        //                        QuotationTable.AddCell(hCell);

        //                        tempStrn = (pdfQuotation.QuotationItemsList[sIndex].Rate == 0) ? "" : pdfQuotation.QuotationItemsList[sIndex].Rate.ToString("#,##0.00");
        //                        hCell = new PdfPCell(new Phrase(tempStrn, CreateFont(StandardFontSize2)));
        //                        hCell.HorizontalAlignment = Element.ALIGN_CENTER;
        //                        hCell.Border = PdfPCell.NO_BORDER;
        //                        QuotationTable.AddCell(hCell);

        //                        tempStrn = (pdfQuotation.QuotationItemsList[sIndex].ItemAmount == 0) ? "" : pdfQuotation.QuotationItemsList[sIndex].ItemAmount.ToString("#,##0.00");
        //                        hCell = new PdfPCell(new Phrase(tempStrn, CreateFont(StandardFontSize2)));
        //                        hCell.HorizontalAlignment = Element.ALIGN_CENTER;
        //                        hCell.Border = PdfPCell.NO_BORDER;
        //                        QuotationTable.AddCell(hCell);

        //                        TotalAmount += pdfQuotation.QuotationItemsList[sIndex].ItemAmount;
        //                    }
        //                    #endregion
        //                }
        //                else if (pdfQuotation.IsInvoice == true)
        //                {
        //                    #region Invoice Item
        //                    //foreach (JLLPOQuotation JPOItem in pdfQuotation.JPOQuotationList)
        //                    for (int sIndex = StartIndex; sIndex < EndIndex; sIndex++)
        //                    {
        //                        tempStrn = (pdfQuotation.QuotationItemsList[sIndex].ItemNo == 0) ? "" : pdfQuotation.QuotationItemsList[sIndex].ItemNo.ToString("00") + ".";
        //                        hCell = new PdfPCell(new Phrase(tempStrn, CreateFont(StandardFontSize2)));
        //                        hCell.HorizontalAlignment = Element.ALIGN_CENTER;
        //                        hCell.Border = PdfPCell.NO_BORDER;
        //                        QuotationTable.AddCell(hCell);

        //                        hCell = new PdfPCell(new Phrase(pdfQuotation.QuotationItemsList[sIndex].ItemDescription, CreateFont(StandardFontSize2)));
        //                        hCell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                        hCell.Border = PdfPCell.NO_BORDER;
        //                        QuotationTable.AddCell(hCell);

        //                        hCell = new PdfPCell(new Phrase(pdfQuotation.QuotationItemsList[sIndex].SORItem, CreateFontWithUnderline(StandardFontSize2)));
        //                        hCell.HorizontalAlignment = Element.ALIGN_CENTER;
        //                        hCell.Border = PdfPCell.NO_BORDER;
        //                        QuotationTable.AddCell(hCell);

        //                        tempStrn = (pdfQuotation.QuotationItemsList[sIndex].Qty == 0) ? "" : pdfQuotation.QuotationItemsList[sIndex].Qty.ToString("0");
        //                        hCell = new PdfPCell(new Phrase(tempStrn, CreateFont(StandardFontSize2)));
        //                        hCell.HorizontalAlignment = Element.ALIGN_CENTER;
        //                        hCell.Border = PdfPCell.NO_BORDER;
        //                        QuotationTable.AddCell(hCell);

        //                        hCell = new PdfPCell(new Phrase(pdfQuotation.QuotationItemsList[sIndex].Unit, CreateFont(StandardFontSize2)));
        //                        hCell.HorizontalAlignment = Element.ALIGN_CENTER;
        //                        hCell.Border = PdfPCell.NO_BORDER;
        //                        QuotationTable.AddCell(hCell);

        //                        tempStrn = (pdfQuotation.QuotationItemsList[sIndex].Rate == 0) ? "" : pdfQuotation.QuotationItemsList[sIndex].Rate.ToString("#,##0.00");
        //                        hCell = new PdfPCell(new Phrase(tempStrn, CreateFont(StandardFontSize2)));
        //                        hCell.HorizontalAlignment = Element.ALIGN_CENTER;
        //                        hCell.Border = PdfPCell.NO_BORDER;
        //                        QuotationTable.AddCell(hCell);

        //                        tempStrn = (pdfQuotation.QuotationItemsList[sIndex].ItemAmount == 0) ? "" : pdfQuotation.QuotationItemsList[sIndex].ItemAmount.ToString("#,##0.00");
        //                        hCell = new PdfPCell(new Phrase(tempStrn, CreateFont(StandardFontSize2)));
        //                        hCell.HorizontalAlignment = Element.ALIGN_CENTER;
        //                        hCell.Border = PdfPCell.NO_BORDER;
        //                        QuotationTable.AddCell(hCell);

        //                        TotalAmount += pdfQuotation.QuotationItemsList[sIndex].ItemAmount;
        //                    }
        //                    #endregion
        //                }
        //                #endregion

        //                #region 2nd Last Row - Empty Row
        //                hCell = new PdfPCell(new Phrase("\n", CreateFont(StandardFontSize2)));
        //                hCell.HorizontalAlignment = Element.ALIGN_CENTER;
        //                hCell.Border = PdfPCell.NO_BORDER;
        //                QuotationTable.AddCell(hCell);

        //                hCell = new PdfPCell(new Phrase("\n", CreateFont(StandardFontSize2)));
        //                hCell.HorizontalAlignment = Element.ALIGN_CENTER;
        //                hCell.Border = PdfPCell.NO_BORDER;
        //                QuotationTable.AddCell(hCell);

        //                hCell = new PdfPCell(new Phrase("\n", CreateFont(StandardFontSize2)));
        //                hCell.HorizontalAlignment = Element.ALIGN_CENTER;
        //                hCell.Border = PdfPCell.NO_BORDER;
        //                QuotationTable.AddCell(hCell);

        //                hCell = new PdfPCell(new Phrase("\n", CreateFont(StandardFontSize2)));
        //                hCell.HorizontalAlignment = Element.ALIGN_CENTER;
        //                hCell.Border = PdfPCell.NO_BORDER;
        //                QuotationTable.AddCell(hCell);

        //                hCell = new PdfPCell(new Phrase("\n", CreateFont(StandardFontSize2)));
        //                hCell.HorizontalAlignment = Element.ALIGN_CENTER;
        //                hCell.Border = PdfPCell.NO_BORDER;
        //                QuotationTable.AddCell(hCell);

        //                hCell = new PdfPCell(new Phrase("\n", CreateFont(StandardFontSize2)));
        //                hCell.HorizontalAlignment = Element.ALIGN_CENTER;
        //                hCell.Border = PdfPCell.NO_BORDER;
        //                QuotationTable.AddCell(hCell);

        //                hCell = new PdfPCell(new Phrase("\n", CreateFont(StandardFontSize2)));
        //                hCell.HorizontalAlignment = Element.ALIGN_CENTER;
        //                hCell.Border = PdfPCell.BOTTOM_BORDER;
        //                QuotationTable.AddCell(hCell);
        //                #endregion

        //                if (currentPage == NoOfPages)
        //                {
        //                    #region 2nd Last Row - Total Amount
        //                    hCell = new PdfPCell(new Phrase("\n", CreateFont(StandardFontSize2)));
        //                    hCell.HorizontalAlignment = Element.ALIGN_CENTER;
        //                    hCell.Border = PdfPCell.NO_BORDER;
        //                    QuotationTable.AddCell(hCell);

        //                    hCell = new PdfPCell(new Phrase("\n", CreateFont(StandardFontSize2)));
        //                    hCell.HorizontalAlignment = Element.ALIGN_CENTER;
        //                    hCell.Border = PdfPCell.NO_BORDER;
        //                    QuotationTable.AddCell(hCell);

        //                    hCell = new PdfPCell(new Phrase("\n", CreateFont(StandardFontSize2)));
        //                    hCell.HorizontalAlignment = Element.ALIGN_CENTER;
        //                    hCell.Border = PdfPCell.NO_BORDER;
        //                    QuotationTable.AddCell(hCell);

        //                    hCell = new PdfPCell(new Phrase("\n", CreateFont(StandardFontSize2)));
        //                    hCell.HorizontalAlignment = Element.ALIGN_CENTER;
        //                    hCell.Border = PdfPCell.NO_BORDER;
        //                    QuotationTable.AddCell(hCell);

        //                    hCell = new PdfPCell(new Phrase("Total Amount:", CreateFont(StandardFontSize2)));
        //                    hCell.HorizontalAlignment = Element.ALIGN_CENTER;
        //                    hCell.Border = PdfPCell.NO_BORDER;
        //                    hCell.Colspan = 2;
        //                    QuotationTable.AddCell(hCell);

        //                    hCell = new PdfPCell(new Phrase(TotalAmount.ToString("#,##0.00"), CreateFont(StandardFontSize2)));
        //                    hCell.HorizontalAlignment = Element.ALIGN_CENTER;
        //                    hCell.Border = PdfPCell.BOTTOM_BORDER;
        //                    QuotationTable.AddCell(hCell);
        //                    #endregion

        //                    #region Last row
        //                    hCell = new PdfPCell(new Phrase("\n", CreateFont(StandardFontSize3)));
        //                    hCell.HorizontalAlignment = Element.ALIGN_CENTER;
        //                    hCell.Border = PdfPCell.NO_BORDER;
        //                    hCell.Colspan = 6;
        //                    QuotationTable.AddCell(hCell);

        //                    hCell = new PdfPCell(new Phrase("\n", CreateFont(StandardFontSize3)));
        //                    hCell.HorizontalAlignment = Element.ALIGN_CENTER;
        //                    hCell.Border = PdfPCell.BOTTOM_BORDER;
        //                    QuotationTable.AddCell(hCell);
        //                    #endregion
        //                }
        //                else
        //                {
        //                    #region 2nd Last Row - Carry Forward
        //                    hCell = new PdfPCell(new Phrase("\n", CreateFont(StandardFontSize2)));
        //                    hCell.HorizontalAlignment = Element.ALIGN_CENTER;
        //                    hCell.Border = PdfPCell.NO_BORDER;
        //                    QuotationTable.AddCell(hCell);

        //                    hCell = new PdfPCell(new Phrase("\n", CreateFont(StandardFontSize2)));
        //                    hCell.HorizontalAlignment = Element.ALIGN_CENTER;
        //                    hCell.Border = PdfPCell.NO_BORDER;
        //                    QuotationTable.AddCell(hCell);

        //                    hCell = new PdfPCell(new Phrase("\n", CreateFont(StandardFontSize2)));
        //                    hCell.HorizontalAlignment = Element.ALIGN_CENTER;
        //                    hCell.Border = PdfPCell.NO_BORDER;
        //                    QuotationTable.AddCell(hCell);

        //                    hCell = new PdfPCell(new Phrase("\n", CreateFont(StandardFontSize2)));
        //                    hCell.HorizontalAlignment = Element.ALIGN_CENTER;
        //                    hCell.Border = PdfPCell.NO_BORDER;
        //                    QuotationTable.AddCell(hCell);

        //                    hCell = new PdfPCell(new Phrase("Carry Forward:", CreateFont(StandardFontSize2)));
        //                    hCell.HorizontalAlignment = Element.ALIGN_CENTER;
        //                    hCell.Border = PdfPCell.NO_BORDER;
        //                    hCell.Colspan = 2;
        //                    QuotationTable.AddCell(hCell);

        //                    hCell = new PdfPCell(new Phrase(TotalAmount.ToString("#,##0.00"), CreateFont(StandardFontSize2)));
        //                    hCell.HorizontalAlignment = Element.ALIGN_CENTER;
        //                    hCell.Border = PdfPCell.BOTTOM_BORDER;
        //                    QuotationTable.AddCell(hCell);
        //                    #endregion

        //                    #region Last row
        //                    hCell = new PdfPCell(new Phrase("\n", CreateFont(StandardFontSize3)));
        //                    hCell.HorizontalAlignment = Element.ALIGN_CENTER;
        //                    hCell.Border = PdfPCell.NO_BORDER;
        //                    hCell.Colspan = 6;
        //                    QuotationTable.AddCell(hCell);

        //                    hCell = new PdfPCell(new Phrase("\n", CreateFont(StandardFontSize3)));
        //                    hCell.HorizontalAlignment = Element.ALIGN_CENTER;
        //                    hCell.Border = PdfPCell.BOTTOM_BORDER;
        //                    QuotationTable.AddCell(hCell);
        //                    #endregion
        //                }

        //                #region Work Completion Date
        //                //if (pdfQuotation.IsJLLOrderQuotation == true || pdfQuotation.IsJLLOrderInvoice == true)
        //                //{
        //                if (currentPage == NoOfPages)
        //                {
        //                    String tempWrkCompletionDate = "Work completion on " + pdfQuotation.WorkCompletionDate.ToString("dd MMMM yyyy", CultureInfo.CreateSpecificCulture("en-US"));
        //                    hCell = new PdfPCell(new Phrase(tempWrkCompletionDate, CreateFont(StandardFontSize2)));
        //                    hCell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                    hCell.Border = PdfPCell.NO_BORDER;
        //                    hCell.Colspan = 7;
        //                    QuotationTable.AddCell(hCell);

        //                    int NoOfItemsOfLastPage = GetNoOfItems(pdfQuotation, StartIndex, EndIndex);
        //                    int tempFontSize = GetFontSize(NoOfItemsOfLastPage, StandardFontSize2, StandardFontSize1);

        //                    hCell = new PdfPCell(new Phrase("\n", CreateFont(tempFontSize)));
        //                    hCell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                    hCell.Border = PdfPCell.NO_BORDER;
        //                    hCell.Colspan = 7;
        //                    QuotationTable.AddCell(hCell);

        //                    hCell = new PdfPCell(new Phrase("\n", CreateFont(tempFontSize)));
        //                    hCell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                    hCell.Border = PdfPCell.NO_BORDER;
        //                    hCell.Colspan = 7;
        //                    QuotationTable.AddCell(hCell);
        //                }
        //                //}
        //                #endregion
        //                #endregion

        //                PDFDoc.Add(QuotationTable);
        //                //p = new Paragraph("\n");
        //                //PDFDoc.Add(p);
        //                #endregion

        //                // Check if the current page is the last page
        //                if (currentPage == NoOfPages)
        //                {
        //                    int NoOfItemsOfLastPage = GetNoOfItems(pdfQuotation, StartIndex, EndIndex);
        //                    int NoOfLines = GetNoOfLines(NoOfItemsOfLastPage, currentPage);
        //                    int tempFontSize = GetFontSize(NoOfItemsOfLastPage, StandardFontSize2, StandardFontSize1, currentPage);

        //                    p = new Paragraph("\n");
        //                    for (int i = 0; i < NoOfLines; i++)
        //                        PDFDoc.Add(p);

        //                    #region Part IV - Remarks
        //                    PdfPTable RemarkTable = new PdfPTable(2);
        //                    RemarkTable.TotalWidth = 500f;
        //                    RemarkTable.LockedWidth = true;

        //                    if (pdfQuotation.IsQuotation == true)
        //                    {
        //                        widths = new float[] { 0.2f, 4f };
        //                        RemarkTable.SetWidths(widths);

        //                        #region Row 1 - Remark Header
        //                        hCell = new PdfPCell(new Phrase("\n", CreateFont(StandardFontSize8)));
        //                        hCell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                        hCell.Border = PdfPCell.NO_BORDER;
        //                        RemarkTable.AddCell(hCell);

        //                        hCell = new PdfPCell(new Phrase("Remarks:", CreateFont(StandardFontSize8)));
        //                        hCell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                        hCell.Border = PdfPCell.NO_BORDER;
        //                        RemarkTable.AddCell(hCell);
        //                        #endregion

        //                        #region Row 2 - Remark a
        //                        hCell = new PdfPCell(new Phrase("\n", CreateFont(StandardFontSize8)));
        //                        hCell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                        hCell.Border = PdfPCell.NO_BORDER;
        //                        RemarkTable.AddCell(hCell);

        //                        hCell = new PdfPCell(new Phrase("a) Quotation Validity: 30 days from the date of this quotation", CreateFont(StandardFontSize8)));
        //                        hCell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                        hCell.Border = PdfPCell.NO_BORDER;
        //                        RemarkTable.AddCell(hCell);
        //                        #endregion

        //                        #region Row 3 - Remark b
        //                        hCell = new PdfPCell(new Phrase("\n", CreateFont(StandardFontSize8)));
        //                        hCell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                        hCell.Border = PdfPCell.NO_BORDER;
        //                        RemarkTable.AddCell(hCell);

        //                        hCell = new PdfPCell(new Phrase("b) Please sign and return for order confirmation if the above quotation is acceptable for you", CreateFont(StandardFontSize8)));
        //                        hCell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                        hCell.Border = PdfPCell.NO_BORDER;
        //                        RemarkTable.AddCell(hCell);
        //                        #endregion
        //                    }
        //                    else if (pdfQuotation.IsInvoice == true)
        //                    {
        //                        #region Row 1 - Remark Header
        //                        String tempString = "** Say Hong Kong Dollars " + NumberUtil.changeCurrencyToWords((double)TotalAmount) + " **";

        //                        hCell = new PdfPCell(new Phrase(tempString, CreateFont(StandardFontSize2)));
        //                        hCell.HorizontalAlignment = Element.ALIGN_CENTER;
        //                        hCell.Border = PdfPCell.NO_BORDER;
        //                        hCell.Colspan = 2;
        //                        RemarkTable.AddCell(hCell);
        //                        #endregion
        //                    }

        //                    #region Row 4 - Empty Row
        //                    hCell = new PdfPCell(new Phrase("\n", CreateFont(tempFontSize)));
        //                    hCell.HorizontalAlignment = Element.ALIGN_CENTER;
        //                    hCell.Border = PdfPCell.NO_BORDER;
        //                    hCell.Colspan = 2;
        //                    RemarkTable.AddCell(hCell);
        //                    #endregion

        //                    #region Row 5 - Empty Row
        //                    hCell = new PdfPCell(new Phrase("\n", CreateFont(tempFontSize)));
        //                    hCell.HorizontalAlignment = Element.ALIGN_CENTER;
        //                    hCell.Border = PdfPCell.NO_BORDER;
        //                    hCell.Colspan = 2;
        //                    RemarkTable.AddCell(hCell);
        //                    #endregion

        //                    #region Row 6 - Empty Row
        //                    hCell = new PdfPCell(new Phrase("\n", CreateFont(tempFontSize)));
        //                    hCell.HorizontalAlignment = Element.ALIGN_CENTER;
        //                    hCell.Border = PdfPCell.NO_BORDER;
        //                    hCell.Colspan = 2;
        //                    RemarkTable.AddCell(hCell);
        //                    #endregion

        //                    PDFDoc.Add(RemarkTable);
        //                    #endregion

        //                    #region Part V - Company Signature & Extra Information
        //                    PdfPTable ComSignTable = new PdfPTable(8);
        //                    ComSignTable.TotalWidth = 500f;
        //                    ComSignTable.LockedWidth = true;
        //                    widths = new float[] { 1f, 3f, 3f, 1f, 1f, 1f, 1f, 2f };
        //                    ComSignTable.SetWidths(widths);

        //                    if (pdfQuotation.IsQuotation == true)
        //                    {
        //                        #region Row 1 - Header Info
        //                        hCell = new PdfPCell(new Phrase("For and on behalf of", CreateEnglishFontWithBold(StandardFontSize)));
        //                        hCell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                        hCell.Border = PdfPCell.NO_BORDER;
        //                        hCell.Colspan = 8;
        //                        ComSignTable.AddCell(hCell);
        //                        #endregion

        //                        #region Row 2 - Header Info 2
        //                        hCell = new PdfPCell(new Phrase("Chung Kai Decoration Works Ltd.", CreateEnglishFontWithBold(StandardFontSize)));
        //                        hCell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                        hCell.Border = PdfPCell.NO_BORDER;
        //                        hCell.Colspan = 5;
        //                        ComSignTable.AddCell(hCell);

        //                        hCell = new PdfPCell(new Phrase("Confirmed and accepted by:", CreateEnglishFontWithBold(StandardFontSize)));
        //                        hCell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                        hCell.Border = PdfPCell.NO_BORDER;
        //                        hCell.Colspan = 3;
        //                        ComSignTable.AddCell(hCell);
        //                        #endregion

        //                        #region Row 3 - Signature
        //                        jpg = Image.GetInstance(pdfQuotation.CompanySignaturePath);
        //                        jpg.ScaleAbsolute(60, 60);
        //                        imageCell = new PdfPCell(jpg);
        //                        imageCell.Border = PdfPCell.NO_BORDER;
        //                        imageCell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                        imageCell.Colspan = 8;
        //                        ComSignTable.AddCell(imageCell);
        //                        #endregion

        //                        #region Row 4 - Empty Row
        //                        hCell = new PdfPCell(new Phrase("\n", CreateEnglishFontWithBold(StandardFontSize3)));
        //                        hCell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                        hCell.Border = PdfPCell.NO_BORDER;
        //                        hCell.Colspan = 8;
        //                        ComSignTable.AddCell(hCell);
        //                        #endregion

        //                        #region Row 5 - Signature Name
        //                        hCell = new PdfPCell(new Phrase("Authorised Signature", CreateEnglishFontWithBold(StandardFontSize)));
        //                        hCell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                        hCell.Border = PdfPCell.TOP_BORDER;
        //                        hCell.Colspan = 2;
        //                        ComSignTable.AddCell(hCell);

        //                        hCell = new PdfPCell(new Phrase("\n", CreateEnglishFontWithBold(StandardFontSize)));
        //                        hCell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                        hCell.Border = PdfPCell.NO_BORDER;
        //                        hCell.Colspan = 3;
        //                        ComSignTable.AddCell(hCell);

        //                        hCell = new PdfPCell(new Phrase("Signature & Company Chop.", CreateEnglishFontWithBold(StandardFontSize)));
        //                        hCell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                        hCell.Border = PdfPCell.TOP_BORDER;
        //                        hCell.Colspan = 3;
        //                        ComSignTable.AddCell(hCell);
        //                        #endregion
        //                    }
        //                    else if (pdfQuotation.IsInvoice == true)
        //                    {
        //                        #region Row 1 - Header Info
        //                        hCell = new PdfPCell(new Phrase("\n", CreateEnglishFontWithBold(StandardFontSize)));
        //                        hCell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                        hCell.Border = PdfPCell.NO_BORDER;
        //                        hCell.Colspan = 5;
        //                        ComSignTable.AddCell(hCell);

        //                        hCell = new PdfPCell(new Phrase("For and on behalf of", CreateEnglishFontWithBold(StandardFontSize)));
        //                        hCell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                        hCell.Border = PdfPCell.NO_BORDER;
        //                        hCell.Colspan = 3;
        //                        ComSignTable.AddCell(hCell);
        //                        #endregion

        //                        #region Row 2 - Header Info 2
        //                        hCell = new PdfPCell(new Phrase("\n", CreateEnglishFontWithBold(StandardFontSize)));
        //                        hCell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                        hCell.Border = PdfPCell.NO_BORDER;
        //                        hCell.Colspan = 5;
        //                        ComSignTable.AddCell(hCell);

        //                        hCell = new PdfPCell(new Phrase("Chung Kai Decoration Works Ltd.", CreateEnglishFontWithBold(StandardFontSize)));
        //                        hCell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                        hCell.Border = PdfPCell.NO_BORDER;
        //                        hCell.Colspan = 3;
        //                        ComSignTable.AddCell(hCell);
        //                        #endregion

        //                        #region Row 3 - Empty Rows
        //                        for (int i = 0; i < 5; i++)
        //                        {
        //                            hCell = new PdfPCell(new Phrase("\n", CreateEnglishFontWithBold(StandardFontSize)));
        //                            hCell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                            hCell.Border = PdfPCell.NO_BORDER;
        //                            hCell.Colspan = 8;
        //                            ComSignTable.AddCell(hCell);
        //                        }
        //                        #endregion

        //                        #region Row 4 - Signature Name
        //                        hCell = new PdfPCell(new Phrase("\n", CreateEnglishFontWithBold(StandardFontSize)));
        //                        hCell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                        hCell.Border = PdfPCell.NO_BORDER;
        //                        hCell.Colspan = 5;
        //                        ComSignTable.AddCell(hCell);

        //                        hCell = new PdfPCell(new Phrase("Authorised Signature", CreateEnglishFontWithBold(StandardFontSize)));
        //                        hCell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                        hCell.Border = PdfPCell.TOP_BORDER;
        //                        hCell.Colspan = 3;
        //                        ComSignTable.AddCell(hCell);
        //                        #endregion
        //                    }

        //                    #region Row 6 - Empty Row
        //                    hCell = new PdfPCell(new Phrase("\n", CreateEnglishFontWithBold(StandardFontSize)));
        //                    hCell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                    hCell.Border = PdfPCell.NO_BORDER;
        //                    hCell.Colspan = 8;
        //                    ComSignTable.AddCell(hCell);
        //                    #endregion

        //                    #region Row 7 - Empty Row
        //                    hCell = new PdfPCell(new Phrase("\n", CreateEnglishFontWithBold(StandardFontSize)));
        //                    hCell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                    hCell.Border = PdfPCell.BOTTOM_BORDER;
        //                    hCell.BorderWidthBottom = 2f;
        //                    hCell.Colspan = 8;
        //                    ComSignTable.AddCell(hCell);
        //                    #endregion

        //                    #region Row 8 - Company Address Chinese
        //                    hCell = new PdfPCell(new Phrase(pdfQuotation.CompanyAddressInChinese, CreateFont(StandardFontSize8, true)));
        //                    hCell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                    hCell.Border = PdfPCell.NO_BORDER;
        //                    hCell.Colspan = 8;
        //                    ComSignTable.AddCell(hCell);
        //                    #endregion

        //                    #region Row 9 - Company Address English
        //                    hCell = new PdfPCell(new Phrase(pdfQuotation.CompanyAddressInEnglish, CreateFont(StandardFontSize8)));
        //                    hCell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                    hCell.Border = PdfPCell.NO_BORDER;
        //                    hCell.Colspan = 8;
        //                    ComSignTable.AddCell(hCell);
        //                    #endregion

        //                    #region Row 10 - Company Extra Info
        //                    hCell = new PdfPCell(new Phrase(pdfQuotation.CompanyExtraInfo, CreateFont(StandardFontSize8)));
        //                    hCell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                    hCell.Border = PdfPCell.NO_BORDER;
        //                    hCell.Colspan = 8;
        //                    ComSignTable.AddCell(hCell);
        //                    #endregion

        //                    PDFDoc.Add(ComSignTable);
        //                    #endregion
        //                }
        //                #endregion
        //            }
        //            else if (pdfQuotation.IsInvoice == true)
        //            {
        //                #region Invoice Part
        //                #region Part III - Invoice
        //                PdfPTable qTable = new PdfPTable(1);
        //                qTable.TotalWidth = 500f;
        //                qTable.LockedWidth = true;
        //                #region Section Header
        //                PdfPCell hCell = new PdfPCell(new Phrase("\n", CreateFont(StandardFontSize3)));
        //                hCell.HorizontalAlignment = Element.ALIGN_CENTER;
        //                hCell.Border = PdfPCell.TOP_BORDER;
        //                qTable.AddCell(hCell);

        //                hCell = new PdfPCell(new Phrase("INVOICE", CreateEnglishFontWithBold(HeaderFontSizeChinese)));
        //                hCell.HorizontalAlignment = Element.ALIGN_CENTER;
        //                hCell.Border = PdfPCell.TOP_BORDER;
        //                qTable.AddCell(hCell);

        //                hCell = new PdfPCell(new Phrase("\n", CreateFont(StandardFontSize3)));
        //                hCell.HorizontalAlignment = Element.ALIGN_CENTER;
        //                hCell.Border = PdfPCell.BOTTOM_BORDER;
        //                qTable.AddCell(hCell);

        //                hCell = new PdfPCell(new Phrase("\n", CreateFont(StandardFontSize3)));
        //                hCell.HorizontalAlignment = Element.ALIGN_CENTER;
        //                hCell.Border = PdfPCell.BOTTOM_BORDER;
        //                qTable.AddCell(hCell);

        //                hCell = new PdfPCell(new Phrase("\n", CreateFont(StandardFontSize3)));
        //                hCell.HorizontalAlignment = Element.ALIGN_CENTER;
        //                hCell.Border = PdfPCell.NO_BORDER;
        //                qTable.AddCell(hCell);
        //                #endregion

        //                PDFDoc.Add(qTable);

        //                #region Application For Payment
        //                PdfPTable SATable = new PdfPTable(1);
        //                SATable.TotalWidth = 500f;
        //                SATable.LockedWidth = true;
        //                widths = new float[] { 6f };
        //                SATable.SetWidths(widths);

        //                hCell = new PdfPCell(new Phrase("Application For Payment", CreateFontWithBoldAndUnderline(StandardFontSize13)));
        //                hCell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                hCell.Border = PdfPCell.NO_BORDER;
        //                SATable.AddCell(hCell);

        //                PDFDoc.Add(SATable);
        //                //p = new Paragraph("\n");
        //                //PDFDoc.Add(p);
        //                #endregion

        //                #region Empty Row
        //                SATable = new PdfPTable(1);
        //                SATable.TotalWidth = 500f;
        //                SATable.LockedWidth = true;
        //                widths = new float[] { 6f };
        //                SATable.SetWidths(widths);

        //                hCell = new PdfPCell(new Phrase("\n\n", CreateFontWithBoldAndUnderline(StandardFontSize2)));
        //                hCell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                hCell.Border = PdfPCell.NO_BORDER;
        //                SATable.AddCell(hCell);

        //                PDFDoc.Add(SATable);
        //                //p = new Paragraph("\n");
        //                //PDFDoc.Add(p);
        //                #endregion

        //                #region Debit Note No
        //                SATable = new PdfPTable(1);
        //                SATable.TotalWidth = 500f;
        //                SATable.LockedWidth = true;
        //                widths = new float[] { 6f };
        //                SATable.SetWidths(widths);

        //                String DebitNoteNo = "RE - " + tempDNOrQuoNo;

        //                hCell = new PdfPCell(new Phrase(DebitNoteNo, CreateFontWithBoldAndUnderline(StandardFontSize13)));
        //                hCell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                hCell.Border = PdfPCell.NO_BORDER;
        //                SATable.AddCell(hCell);

        //                PDFDoc.Add(SATable);
        //                #endregion

        //                #region Amount
        //                SATable = new PdfPTable(1);
        //                SATable.TotalWidth = 500f;
        //                SATable.LockedWidth = true;
        //                widths = new float[] { 6f };
        //                SATable.SetWidths(widths);

        //                hCell = new PdfPCell(new Phrase("Amount", CreateFontWithBoldAndUnderline(StandardFontSize13)));
        //                hCell.HorizontalAlignment = Element.ALIGN_RIGHT;
        //                hCell.Border = PdfPCell.NO_BORDER;
        //                SATable.AddCell(hCell);

        //                PDFDoc.Add(SATable);
        //                p = new Paragraph("\n");
        //                PDFDoc.Add(p);
        //                #endregion

        //                #region Amount Table
        //                PdfPTable AmountTable = new PdfPTable(2);
        //                AmountTable.TotalWidth = 500f;
        //                AmountTable.LockedWidth = true;
        //                widths = new float[] { 5f, 2f };
        //                AmountTable.SetWidths(widths);

        //                #region Row 1 - Agreed Total Sum
        //                String tempStrn = "Agreed Total Sum as per attached table " + tempDNOrQuoNo;

        //                bool isFoundFM = fmRepsoitory.IsFMFound(pdfQuotation.Invoice.DNNo.Split('-')[0]);

        //                if(isFoundFM == true)
        //                    tempStrn = "Agreed Total Sum as per quotation " + tempDNOrQuoNo;

        //                PdfPCell cell = new PdfPCell(new Phrase(tempStrn, CreateFont(StandardFontSize2)));
        //                cell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                cell.Border = PdfPCell.NO_BORDER;
        //                AmountTable.AddCell(cell);

        //                cell = new PdfPCell(new Phrase("", CreateFont(StandardFontSize2)));
        //                cell.HorizontalAlignment = Element.ALIGN_RIGHT;
        //                cell.Border = PdfPCell.NO_BORDER;
        //                AmountTable.AddCell(cell);
        //                #endregion

        //                #region Row 2 - 100% Upon Practical Completion
        //                tempStrn = "100% Upon Practical Completion";
        //                cell = new PdfPCell(new Phrase(tempStrn, CreateFont(StandardFontSize2)));
        //                cell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                cell.Border = PdfPCell.NO_BORDER;
        //                AmountTable.AddCell(cell);

        //                tempStrn = "HK$ " + pdfQuotation.Invoice.TotalAmount.ToString("#,##0.00");
        //                cell = new PdfPCell(new Phrase(tempStrn, CreateFont(StandardFontSize2)));
        //                cell.HorizontalAlignment = Element.ALIGN_RIGHT;
        //                cell.Border = PdfPCell.NO_BORDER;
        //                AmountTable.AddCell(cell);
        //                #endregion

        //                #region Row 3 - Less Previous Claimed
        //                cell = new PdfPCell(new Phrase("Less Previous Claimed", CreateFont(StandardFontSize2)));
        //                cell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                cell.Border = PdfPCell.NO_BORDER;
        //                AmountTable.AddCell(cell);

        //                cell = new PdfPCell(new Phrase("Nil", CreateFont(StandardFontSize2)));
        //                cell.HorizontalAlignment = Element.ALIGN_RIGHT;
        //                cell.Border = PdfPCell.BOTTOM_BORDER;
        //                AmountTable.AddCell(cell);
        //                #endregion

        //                #region Row 4 - This Invoice Amount
        //                cell = new PdfPCell(new Phrase("This Invoice Amount", CreateFont(StandardFontSize2)));
        //                cell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                cell.Border = PdfPCell.NO_BORDER;
        //                AmountTable.AddCell(cell);

        //                tempStrn = "HK$ " + pdfQuotation.Invoice.TotalAmount.ToString("#,##0.00");
        //                cell = new PdfPCell(new Phrase(tempStrn, CreateFont(StandardFontSize2)));
        //                cell.HorizontalAlignment = Element.ALIGN_RIGHT;
        //                cell.Border = PdfPCell.BOTTOM_BORDER;
        //                AmountTable.AddCell(cell);
        //                #endregion

        //                #region Row 5 - Last Row
        //                cell = new PdfPCell(new Phrase("\n", CreateFont(StandardFontSize3)));
        //                cell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                cell.Border = PdfPCell.NO_BORDER;
        //                AmountTable.AddCell(cell);

        //                cell = new PdfPCell(new Phrase("\n", CreateFont(StandardFontSize3)));
        //                cell.HorizontalAlignment = Element.ALIGN_RIGHT;
        //                cell.Border = PdfPCell.BOTTOM_BORDER;
        //                AmountTable.AddCell(cell);
        //                #endregion

        //                PDFDoc.Add(AmountTable);
        //                p = new Paragraph("\n\n\n\n\n\n");
        //                PDFDoc.Add(p);
        //                #endregion

        //                #region Part IV - Remarks
        //                PdfPTable RemarkTable = new PdfPTable(2);
        //                RemarkTable.TotalWidth = 500f;
        //                RemarkTable.LockedWidth = true;

        //                #region Row 1 - Remark Header
        //                String tempString = "** Say Hong Kong Dollars " + NumberUtil.changeCurrencyToWords((double)pdfQuotation.Invoice.TotalAmount) + " **";

        //                hCell = new PdfPCell(new Phrase(tempString, CreateFont(StandardFontSize2)));
        //                hCell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                hCell.Border = PdfPCell.NO_BORDER;
        //                hCell.Colspan = 2;
        //                RemarkTable.AddCell(hCell);
        //                #endregion

        //                PDFDoc.Add(RemarkTable);
        //                p = new Paragraph("\n\n\n\n\n");
        //                PDFDoc.Add(p);
        //                #endregion

        //                #region Part V - Company Signature & Extra Information
        //                PdfPTable ComSignTable = new PdfPTable(8);
        //                ComSignTable.TotalWidth = 500f;
        //                ComSignTable.LockedWidth = true;
        //                widths = new float[] { 1f, 3f, 3f, 1f, 1f, 1f, 1f, 2f };
        //                ComSignTable.SetWidths(widths);

        //                #region Row 1 - Header Info
        //                hCell = new PdfPCell(new Phrase("\n", CreateEnglishFontWithBold(StandardFontSize)));
        //                hCell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                hCell.Border = PdfPCell.NO_BORDER;
        //                hCell.Colspan = 5;
        //                ComSignTable.AddCell(hCell);

        //                hCell = new PdfPCell(new Phrase("For and on behalf of", CreateEnglishFontWithBold(StandardFontSize)));
        //                hCell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                hCell.Border = PdfPCell.NO_BORDER;
        //                hCell.Colspan = 3;
        //                ComSignTable.AddCell(hCell);
        //                #endregion

        //                #region Row 2 - Header Info 2
        //                hCell = new PdfPCell(new Phrase("\n", CreateEnglishFontWithBold(StandardFontSize)));
        //                hCell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                hCell.Border = PdfPCell.NO_BORDER;
        //                hCell.Colspan = 5;
        //                ComSignTable.AddCell(hCell);

        //                hCell = new PdfPCell(new Phrase("Chung Kai Decoration Works Ltd.", CreateEnglishFontWithBold(StandardFontSize)));
        //                hCell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                hCell.Border = PdfPCell.NO_BORDER;
        //                hCell.Colspan = 3;
        //                ComSignTable.AddCell(hCell);
        //                #endregion

        //                #region Row 3 - Empty Rows
        //                for (int i = 0; i < 5; i++)
        //                {
        //                    hCell = new PdfPCell(new Phrase("\n", CreateEnglishFontWithBold(StandardFontSize)));
        //                    hCell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                    hCell.Border = PdfPCell.NO_BORDER;
        //                    hCell.Colspan = 8;
        //                    ComSignTable.AddCell(hCell);
        //                }
        //                #endregion

        //                #region Row 4 - Signature Name
        //                hCell = new PdfPCell(new Phrase("\n", CreateEnglishFontWithBold(StandardFontSize)));
        //                hCell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                hCell.Border = PdfPCell.NO_BORDER;
        //                hCell.Colspan = 5;
        //                ComSignTable.AddCell(hCell);

        //                hCell = new PdfPCell(new Phrase("Authorised Signature", CreateEnglishFontWithBold(StandardFontSize)));
        //                hCell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                hCell.Border = PdfPCell.TOP_BORDER;
        //                hCell.Colspan = 3;
        //                ComSignTable.AddCell(hCell);
        //                #endregion

        //                #region Row 6 - Empty Row
        //                hCell = new PdfPCell(new Phrase("\n", CreateEnglishFontWithBold(StandardFontSize)));
        //                hCell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                hCell.Border = PdfPCell.NO_BORDER;
        //                hCell.Colspan = 8;
        //                ComSignTable.AddCell(hCell);
        //                #endregion

        //                #region Row 7 - Empty Row
        //                hCell = new PdfPCell(new Phrase("\n", CreateEnglishFontWithBold(StandardFontSize)));
        //                hCell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                hCell.Border = PdfPCell.BOTTOM_BORDER;
        //                hCell.BorderWidthBottom = 2f;
        //                hCell.Colspan = 8;
        //                ComSignTable.AddCell(hCell);
        //                #endregion

        //                #region Row 8 - Company Address Chinese
        //                hCell = new PdfPCell(new Phrase(pdfQuotation.CompanyAddressInChinese, CreateFont(StandardFontSize8, true)));
        //                hCell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                hCell.Border = PdfPCell.NO_BORDER;
        //                hCell.Colspan = 8;
        //                ComSignTable.AddCell(hCell);
        //                #endregion

        //                #region Row 9 - Company Address English
        //                hCell = new PdfPCell(new Phrase(pdfQuotation.CompanyAddressInEnglish, CreateFont(StandardFontSize8)));
        //                hCell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                hCell.Border = PdfPCell.NO_BORDER;
        //                hCell.Colspan = 8;
        //                ComSignTable.AddCell(hCell);
        //                #endregion

        //                #region Row 10 - Company Extra Info
        //                hCell = new PdfPCell(new Phrase(pdfQuotation.CompanyExtraInfo, CreateFont(StandardFontSize8)));
        //                hCell.HorizontalAlignment = Element.ALIGN_LEFT;
        //                hCell.Border = PdfPCell.NO_BORDER;
        //                hCell.Colspan = 8;
        //                ComSignTable.AddCell(hCell);
        //                #endregion

        //                PDFDoc.Add(ComSignTable);
        //                #endregion
        //                #endregion
        //                #endregion
        //            }
        //        }
        //        PDFDoc.Close();
        //        isSuccess = true;
        //    }
        //    catch (Exception e)
        //    {
        //    }

        //    return isSuccess;
        //}

        //private static int GetNoOfLines(int NoOfItems, int CurrentPage = 1)
        //{
        //    int result = 7;

        //    if ((NoOfItems >= 3 && NoOfItems <= 6))
        //        result = 4;
        //    else if ((NoOfItems >= 7 && NoOfItems <= 9))
        //        result = 2;
        //    else
        //        result = 0;

        //    return result;
        //}

        //private static int GetFontSize(int NoOfItems, int BigFontSize, int SmallFontSize, int CurrentPage = 1)
        //{
        //    int result = BigFontSize;

        //    if ((NoOfItems >= 6 && NoOfItems <= 13) || CurrentPage > 1)
        //        result = SmallFontSize;

        //    return result;
        //}

        //private static int GetNoOfItems(PDF_QuotationInvoiceModel pdfQuotation, int StartIndex, int EndIndex)
        //{
        //    List<QuotationItemModel> tempList = new List<QuotationItemModel>();

        //    for (int i = StartIndex; i < EndIndex; i++)
        //        tempList.Add(pdfQuotation.QuotationItemsList[i]);

        //    return tempList.Count;
        //}

        //private static int GetStartIndex(PDF_QuotationInvoiceModel pdfQuotation, int currentPageNo)
        //{
        //    return currentPageNo * pdfQuotation.MaxNoOfRecords;
        //}

        //private static int GetEndIndex(PDF_QuotationInvoiceModel pdfQuotation, int currentPageNo, int NoOfPages)
        //{
        //    int ResultIndex = (currentPageNo * pdfQuotation.MaxNoOfRecords);

        //    if (currentPageNo == NoOfPages)
        //    {
        //        ResultIndex = pdfQuotation.QuotationItemsList.Count;
        //        //if (pdfQuotation.IsQuotation == true || pdfQuotation.IsJLLOrderInvoice == true)
        //        //    ResultIndex = pdfQuotation.QuotationList.Count;
        //        //else if (pdfQuotation.IsJLLPOQuotation == true || pdfQuotation.IsJLLPOInvoce == true)
        //        //    ResultIndex = pdfQuotation.QuotationList.Count;
        //    }

        //    return ResultIndex;
        //}

        //public static Font CreateFont(float FontSize, bool isChinese = false)
        //{
        //    BaseFont baseFT = BaseFont.CreateFont(Configuration.CompanyFontForEng, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
        //    if (isChinese == true)
        //        baseFT = BaseFont.CreateFont(Configuration.CompanyFontForChi, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);

        //    Font font = new Font(baseFT, FontSize);
        //    return font;
        //}

        //public static Font CreateEnglishFontWithBold(float FontSize)
        //{
        //    BaseFont baseFT = BaseFont.CreateFont(Configuration.CompanyFontForEng, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
        //    Font font = new Font(baseFT, FontSize, Font.BOLD);
        //    return font;
        //}

        //public static Font CreateChineseFontWithBold(float FontSize)
        //{
        //    BaseFont baseFT = BaseFont.CreateFont(Configuration.CompanyFontForChi, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
        //    Font font = new Font(baseFT, FontSize, Font.BOLD);
        //    return font;
        //}

        //public static Font CreateFontWithBoldAndUnderline(int FontSize, bool isChinese = false)
        //{
        //    BaseFont baseFT = BaseFont.CreateFont(Configuration.CompanyFontForEng, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
        //    if (isChinese == true)
        //        baseFT = BaseFont.CreateFont(Configuration.CompanyFontForChi, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);

        //    Font font = new Font(baseFT, FontSize, Font.BOLD | Font.UNDERLINE);
        //    return font;
        //}

        //public static Font CreateFontWithUnderline(float FontSize)
        //{
        //    BaseFont baseFT = BaseFont.CreateFont(Configuration.CompanyFontForEng, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
        //    Font font = new Font(baseFT, FontSize, Font.UNDERLINE);
        //    return font;
        //}
    }
}